package com.spider.im.chat.controller;


import com.spider.im.chat.req.ChatGroupReq;
import com.spider.im.chat.req.ChatGroupUserReq;
import com.spider.im.chat.service.ChatGroupService;
import com.spider.im.chat.service.ChatGroupUserService;
import com.spider.im.common.aspect.RespResult;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 聊天群组表 前端控制器
 * </p>
 *
 * @author joy
 * @since 2025-04-23
 */
@Tag(name = "ChatGroupController",  description = "群组管理")
@RestController
@RequestMapping("/api/chat/group")
public class ChatGroupController {

    @Resource
    private ChatGroupService chatGroupService;

    @Resource
    private ChatGroupUserService chatGroupUserService;
    /**
     * 新增群组接口
     */
    @Operation(summary = "新增群组接口")
    @PostMapping("/addGroup")
    public RespResult<Long> addGroup(@RequestBody @Validated ChatGroupReq chatGroupReq) {

        return RespResult.success(chatGroupService.saveGroup(chatGroupReq));
    }


    /**
     * 新增群组用户接口
     */
    @Operation(summary = "新增群组用户接口")
    @PostMapping("/addGroupUser")
    public RespResult<List<Long>> addGroupUser(@RequestBody @Validated ChatGroupUserReq chatGroupUserReq) {

        return RespResult.success(chatGroupUserService.saveGroupUser(chatGroupUserReq));
    }
}

